package org.qfbl.nio;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class MappedByteFufferTest {
    public static void main(String[] args) throws IOException {
        RandomAccessFile randomAccessFile = new RandomAccessFile("E:\\JavaCode\\netty_project\\file\\01file.txt","rw");
        FileChannel channel = randomAccessFile.getChannel();
        MappedByteBuffer byteBuffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, 5);
        byteBuffer.put(0, (byte) 'H');
        byteBuffer.put(3, (byte) 'H');

        randomAccessFile.close();

    }
}
